﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
using FairyGUI.Utils;
using UnityEngine.Events;
public class UI_Message : Window
{
    public UI_TipWindow m_frame;
    public UnityAction callback;
    protected override void OnInit()
    {
        base.OnInit();
        this.contentPane = UIManager.Instance.LoadComponent("Login", "UIMessage");
        m_frame = (UI_TipWindow)this.contentPane.GetChild("frame");
    }

    /// <summary>
    /// 当窗口显示时,调用
    /// </summary>
    protected override void OnShown()
    {
        base.OnShown();
        Debug.LogFormat("OnShown...");
    }

    /// <summary>
    /// 当窗口隐藏时,调用
    /// </summary>
    protected override void OnHide()
    {
        base.OnHide();
        if (callback != null)
        {
            callback();
            callback = null;
        }
    }

    public void Message(string message, UnityAction cb=null)
    {
        m_frame.Message(message);
        callback = cb;
    }

    protected override void DoShowAnimation()
    {
        this.contentPane.GetTransition("show").Play(base.DoShowAnimation);
    }

    protected override void DoHideAnimation()
    {
        this.contentPane.GetTransition("hide").Play(base.DoHideAnimation);
    }
}
